package com.xc.hotelmgr.webapi.modules.ht.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.Query;

import com.xc.hotelmgr.webapi.modules.ht.dao.HtCityinfoDao;
import com.xc.hotelmgr.webapi.modules.ht.entity.HtCityinfoEntity;
import com.xc.hotelmgr.webapi.modules.ht.service.HtCityinfoService;


@Service("htCityinfoService")
public class HtCityinfoServiceImpl extends ServiceImpl<HtCityinfoDao, HtCityinfoEntity> implements HtCityinfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Object cityNameZh = params.get("cityNameZh");
        IPage<HtCityinfoEntity> page = this.page(
                new Query<HtCityinfoEntity>().getPage(params),
                new QueryWrapper<HtCityinfoEntity>().like(cityNameZh != null,"city_name_zh",cityNameZh)
        );
        return new PageUtils(page);
    }

    @Override
    public List<HtCityinfoEntity> queryData(Map<String, Object> params) {
        String tier = (String) params.get("tier");
        String parentId = (String) params.get("parentId");
        return baseMapper.selectList(new QueryWrapper<HtCityinfoEntity>().eq(tier!=null,"tier",tier)
        .eq(parentId !=null,"parent_city_code",parentId));
    }


}